﻿<%--
 *  File:    VisitPlanAddPop.jsp
 *  @Author: KentZhong 
 *  Date:    2009-10-9 10:02:44
 *
 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>


<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<%

  //String strTableName = "v_visitplancustomer";
    String strModuleName = "SFE";
	String contextPath = request.getContextPath();
	HashMap Cuserinfo = (HashMap)session.getAttribute("userinfo");
   	if (Cuserinfo==null){
   		Cuserinfo = new HashMap();
   	}
%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title><%=label.getLabelName("L_AddOther")%></title>
<%
if("Y".equals(request.getParameter("isconfirm"))){%>

<script>
	opener.refreshWindow();
</script>
<%return;
}%>	
<iframe name="reloadHandler" style="display:none"></iframe>
<PageFlow:CheckPageFlow pageName="p_visitplanaddotherpop"/>

<%
int nYear=((Integer)pageContext.getAttribute("year")).intValue();
int nMonth=((Integer)pageContext.getAttribute("monthofyear")).intValue();
int nWeek=((Integer)pageContext.getAttribute("weekofmonth")).intValue();
int nDay=((Integer)pageContext.getAttribute("dayofweek")).intValue();
Date dStartDate=(Date)pageContext.getAttribute("weekstart");
Calendar cal=null;
if(nYear>0 && nMonth>0 && nWeek>0)
{
	cal=Calendar.getInstance();
	cal.clear();
	cal.setTime(dStartDate);
	cal.add(Calendar.DATE,nDay-1);
	cal.setFirstDayOfWeek(Calendar.MONDAY);
 }
 nYear=cal.get(Calendar.YEAR);
 nMonth=cal.get(Calendar.MONTH)+1;
 nWeek=cal.get(Calendar.WEEK_OF_MONTH);
 
 pageContext.setAttribute("year",new Integer(nYear));
 pageContext.setAttribute("monthofyear",new Integer(nMonth));
 pageContext.setAttribute("weekofmonth",new Integer(nWeek));
 
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");
String strVisitDate=sdf.format(cal.getTime());
java.text.SimpleDateFormat sdfVisit=new java.text.SimpleDateFormat((String)session.getAttribute("dateformat"));
String strVisitDateShow=sdfVisit.format(cal.getTime());
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>

<script language="JavaScript">
<%--  put your custom script here   --%>

function page_cancel()
{
	window.close();
}
function page_confirm()
{
	var myform = eval("document.cform");
	
	
	
  var sstart=eval("myform.splanstarttime");
  var send=eval("myform.splanendtime");
  var tsstart=eval("myform.tsplanstarttime");
  var tsend=eval("myform.tsplanendtime");
  var dvisit=eval("myform.planvisitdate");
  var activitytype=eval("myform.activitytype");
  var remark=eval("myform.remark");
  var processid=eval("myform.processid");
		if(isEmpty(activitytype.value))
		{
			alert("<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_PlanActivityType"))%>");
					return;
		}
    /*
    if(activitytype.value!=2)
	{
	if(activitytype.value==3)
	{
		if(isEmpty(remark.value))
		{
			alert("<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Comment"))%>");
					return;
			}
		}
  	*/	
  		sstart.value=dvisit.value+" "+"01:00:00";
		send.value=dvisit.value+" "+"01:00:00";
  	
  	 
    myform.actionname.value = "add";
 	myform.target="_self";
 	isRunning = true;
 	myform.submit();
}	


function chooseremark(){
	var myform = eval("document.cform");
	var remark=eval("myform.remark");
	var activitytype=eval("myform.activitytype");
	if(activitytype.value==3)
	{
		remark.disabled="";
		}else{
			remark.disabled="disabled";
			remark.value="";
			}
	
	
}
function page_processview()
{
	var myform = eval("document.cform");
	var activitytype=document.cform.activitytype.value;
	var contactid=document.cform.contactid.value;
	var  datahandler = new  DataHandler() ;
	datahandler.add_params("activitytype" , activitytype,"integer") ;
	datahandler.add_params("contactid" , contactid,"integer") ;
	datahandler.getResultFromVector("allprocesses","processname" ,"visitprocessid" ,"document.cform.processid") ;
	datahandler.add_job("j_zylvisitprocess") ;
	datahandler.runDataHandler ();
}
</script>
</head>
<body>
	<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_visitplanaddotherpop">
    <input type="hidden" name="actionname">
    
    <custom:hidden property="orgid"/>
    <custom:hidden property="year"/>
    <custom:hidden property="monthofyear"/>
    <custom:hidden property="weekofmonth"/>
    <custom:hidden property="dayofweek"/>
    <custom:hidden property="ishistory"/>	
    <custom:hidden property="visitplanid" />
    <custom:hidden property="weekstart"/>
    <custom:hidden property="weekend" />	
    <custom:hidden property="contactid" />	
    <custom:hidden property="plantype" />
    <custom:hidden property="detailsstatus" />
    <custom:hidden property="weekstartweekofmonth" />	
    <input type="hidden" name="planvisitdate" value="<%=strVisitDate%>"/>	
   <table width="100%" cellspacing="0" border="0" cellpadding="0">
     
      <tr>
        <td>
         <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
           <tr> 
              <td class="need" width="20%"><%=label.getLabelName("L_PlanActivityType")%><%=label.getLabelName("L_Colon")%></td>
             <td width="30%">
               <custom:selectdic  property="activitytype" dictType="ZVisitProcessType" valueCriteria="3-max" onchange="javascript:page_processview()"  defaultValueCost=" " defaultValue="--------"/>
               <!--  onclick="chooseremark();" -->
           		
             </td>
             <td class="td-text" width="20%"><%=label.getLabelName("L_PlanActivityDate")%><%=label.getLabelName("L_Colon")%></td>
             <td width="30%"> <%=strVisitDateShow%></td>
           </tr>
            <tr> 
             <td class="td-text" height="12"><%=label.getLabelName("L_VisitProcess")%><%=label.getLabelName("L_Colon")%></td>
             <td>&nbsp;
              <custom:select name="onevisitdetail" property="processid" optionsName="allprocesses" optionValueKey="visitprocessid" optionInnerTextKey="processname" defaultValue="---" defaultValueCost=" " />
             </td>
             <td class="td-text">&nbsp;</td>
             <td>&nbsp;</td>
           </tr>
            <tr>
             <td  class="td-text"><%=label.getLabelName("L_Comment")%><%=label.getLabelName("L_Colon")%></td>
           	<td colspan="3">
           	     <input type="hidden" name="splanstarttime" />		
           		<input type="hidden"  name="tsplanstarttime"    value="" />
             	<input type="hidden"   name="tsplanendtime"    value=""  />
             	<input type="hidden" name="splanendtime" />	
             	<textarea style="width:350" rows="3" name="remark" id="remarkid" ></textarea>
           	<!--<custom:textarea property="remark" rows="3" style="width:350" value=""  readonly="true"></custom:textarea>-->
           	</td>
           </tr> 
           
          </table>
         
        </td>
      </tr>
      <tr>
      	<td>
      		<table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
                <a onclick="page_confirm();"><custom:button type="1" label="L_Confirm" imgsrc="new.gif" border="0" style="width:60"/></a>
                <a onclick="page_cancel();"><custom:button type="1" label="L_Cancel" imgsrc="Modify.gif" border="0" style="width:60"/></a>
              </td>
            </tr>
          </table>  
        </td>
      </tr>
    </table>
  </form>             	
</body>

</html>
	
